<?php
/**
 * Characters controller file.
 *
 * Infectamic: browser game (http://infectamic.goldzoneweb.info)
 * Copyright 2011, Loic Chardonnet
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 */

/**
 * Class for Characters controller.
 */
class CharactersController extends AppController {
    var $name = 'Characters';
    var $scaffold;

    /**
     * Controller for index page.
     */
    public function index() {
        $this->Character->recursive = 0;
        $characters = $this->paginate();
        if (false === $characters) {
            $characters = array();
        }
        $this->set('characters', $characters);
    }

    /**
     * Controller for view page.
     *
     * @param mixed $id Character ID, or NULL
     */
    public function view($id = null) {
        if (null === $id) {
            $this->Session->setFlash(__('Invalid character', true));
            $this->redirect(array('action' => 'index'));
        }
        $this->set('character', $this->Character->read(null, $id));
    }
}
